ARD2  RC2
Airbag Reference Demonstrator using MPC5604P
freemaster_bdm.c
Go to the documentation of this file.
00001 /******************************************************************************
00002 *
00003 * Freescale Semiconductor Inc.
00004 * (c) Copyright 2004-2011 Freescale Semiconductor
00005 * ALL RIGHTS RESERVED.
00006 *
00007 ****************************************************************************/
00019 #include "freemaster.h"
00020 #include "freemaster_private.h"
00021 #include "freemaster_protocol.h"
00022 
00023 #if FMSTR_USE_PDBDM
00024 typedef struct
00025 {
00026         FMSTR_U16 buffBorder1;                 // Border code of Packet driven BDM communication buffer
00027         FMSTR_U8 buffSize;                     // Size of Packet driven BDM communication buffer
00028         FMSTR_U8 bdmState;                     // State of the Packet driven BDM communication
00029         FMSTR_BCHR commBuffer[FMSTR_COMM_BUFFER_SIZE+1]; //FreeMASTER Packet driven BDM communication buffer (in/out) plus the STS
00030         FMSTR_U16 buffBorder2;                 // Border code of Packet driven BDM communication buffer
00031 }FMSTR_PDBDM_COMBUFF;
00032 
00033 static FMSTR_PDBDM_COMBUFF pcm_bdm_pCommBuffer; //Packet driven communication buffer
00034 
00035 /**************************************************************************/
00041 void FMSTR_InitPDBdm(void)
00042 {   
00043         /* Initialize buffer border and size in communication buffer */
00044         pcm_bdm_pCommBuffer.buffBorder1 = FMSTR_PDBDM_BUFFBORDER_CODE1;
00045         pcm_bdm_pCommBuffer.buffSize = FMSTR_COMM_BUFFER_SIZE + 1;
00046         pcm_bdm_pCommBuffer.buffBorder2 = FMSTR_PDBDM_BUFFBORDER_CODE2;
00047 
00048         /* initialize state variables */
00049         pcm_bdm_pCommBuffer.bdmState = FMSTR_PDBDM_IDLE;
00050 }
00051 
00052 /**************************************************************************/
00064 void FMSTR_SendResponse(FMSTR_BPTR pResponse, FMSTR_SIZE8 nLength)
00065 {
00066         FMSTR_UNUSED(pResponse);
00067         FMSTR_UNUSED(nLength);
00068         /* Frame is ready to send */
00069         pcm_bdm_pCommBuffer.bdmState = FMSTR_PDBDM_FRAME_TO_SEND;
00070 }
00071 
00072 /*******************************************************************************
00073 *
00074 * @brief    API: Main "Polling" call from the application main loop
00075 *
00076 *******************************************************************************/
00077 
00078 void FMSTR_Poll(void)
00079 { 
00080         if (pcm_bdm_pCommBuffer.bdmState == FMSTR_PDBDM_RECEIVED_FRAME)
00081         {
00082                 /* Packet is received */ 
00083                 pcm_bdm_pCommBuffer.bdmState = FMSTR_PDBDM_DECODING_FRAME;
00084                 /* Decode packet and create response */
00085                 FMSTR_ProtocolDecoder(pcm_bdm_pCommBuffer.commBuffer);
00086         }
00087 }
00088 #else /* FMSTR_USE_PDBDM */
00089 
00090 /*lint -efile(766, freemaster_protocol.h) include file is not used in this case */
00091 
00092 #endif /* FMSTR_USE_PDBDM */
00093 
00094 
00095 
00096